package GoodsService

import (
	"context"
	"gdshop-back-end-go/client-api/app/response/GoodsResp"
	"gdshop-back-end-go/common/request/GoodsReq"
	"gdshop-back-end-go/common/response"
	"gdshop-back-end-go/service-common/ClassifyService"
)

func FilterData(ctx context.Context, parames *GoodsReq.FilterData) *response.JsonResponse {
	var sortList []*GoodsResp.FilterDataSortItem
	sortList = append(sortList, &GoodsResp.FilterDataSortItem{
		Key:  "recommend",
		Name: "综合推荐",
	})
	sortList = append(sortList, &GoodsResp.FilterDataSortItem{
		Key:  "new",
		Name: "新品",
	})
	sortList = append(sortList, &GoodsResp.FilterDataSortItem{
		Key:  "comments",
		Name: "评论数",
	})
	sortList = append(sortList, &GoodsResp.FilterDataSortItem{
		Key:  "price_desc",
		Name: "价格高到低",
	})
	sortList = append(sortList, &GoodsResp.FilterDataSortItem{
		Key:  "price_asc",
		Name: "价格低到高",
	})
	result := GoodsResp.FilterData{
		SortList:     sortList,
		ClassifyList: ClassifyService.Tree(ctx),
		SelectedSort: 0,
	}
	return response.SuccessByRequestMessageData(nil, "成功", result)
}
